import argparse

import utils


def run():
    utils.sleep(opt.sleep)
    if opt.client:
        host, port = utils.hp_parser(opt.client)
        extra_msg = '' if not opt.sleep else f'sleep for {opt.sleep}'
        utils.client(host, port, extra=extra_msg)
    elif opt.server:
        utils.server(opt.server)
    else:
        raise NotImplementedError


if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument('--client', type=str, default='', help='192.168.0.215:554')
    parser.add_argument('--server', type=int, default=0, help='server port')
    parser.add_argument('--sleep', type=int, default=0, help='sleep before launch')
    opt = parser.parse_args()
    print('opt\n', opt)

    run()
